package com.zpark;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;

/**
 * 实现ServletContext02与ServletContext03通信
 * 1、ServletContext02存储数据
 * 2、ServletContext03获取数据
 */
@WebServlet("/c2.do")
public class ServletContext02 extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// 获取context对象
		ServletContext context = request.getServletContext();
		// 获取上下应用文初始化参数
		Enumeration<String> names = context.getInitParameterNames();
		// context.setInitParameter()该方法相当于context-param标签

		// 往context对象当中存储数据
		context.setAttribute("dc", "大锤");
	}
}
